#!/usr/bin/perl
#author yuyuan crazypg@gmail.com

$linenum=1;

while(defined($line = <>)){
	if($linenum == 3){
		chomp($line);

		my @args = split /\s+/ , $line ;
		$cpusage = 100 - $args[ $#args ];
	};
	$linenum = $linenum + 1;
};

if($cpusage > 80){
	print "CPU usage is : " , $cpusage , "% [CRITICAL]\n";
}elsif($cpusage > 60){
	print "CPU usage is : " , $cpusage , "% [WARNING]\n";
}else{
	print "CPU usage is : " , $cpusage , "% [OK]\n";
}

print "| cpusage = $cpusage","%"," ;60;80;0;100\n"
